<?php
include('top.php');
require_once('pasmy/dbwaarden.php');
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db("roussel", $mysql_id);

/*$mysqli = new mysqli("127.0.0.1", "serge", "ss8800ss", "roussel");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";*/

if(isset($_POST["Login"])){
	$_SESSION['taal'] = $_POST["taal"];
	$logon = $_POST["wachtwoord"]; //echo "<h3>logon = |$logon|</h3>";
	$sql = "select * from toegang";
	$res = mysql_query($sql, $mysql_id);
	$fout = mysql_errno($mysql_id);
	if($fout != 0) {
		$fout = mysql_error($mysql_id);
		echo '<div style="text-align: center"><h3><font color = "#FF2306">' . $fout . '</font></h3></div>';
		mysql_close($mysql_id);
		echo '</body></html>';
		exit;
	}
	$niveau = "geen";
	while ($row = mysql_fetch_row($res)) {
		if($logon == $row[0]) { $niveau = $row[1];}
	}
	//echo "<h3>Niveau is nu $niveau</h3>";
	if($niveau != "geen") { $_SESSION["login"] = $niveau; 
		$_SESSION['ingelogd'] = "erin";
		Header( "HTTP/1.1 301 Moved Permanently" );
		 
		Header( "Location: index.php" );} 
		else {
		session_destroy();
		Header( "HTTP/1.1 301 Moved Permanently" );
		 
		Header( "Location: login.php" ); 
		}
	
	
}
?>
	<br /><br /><br />
	<form action="login.php" method="post">
	<table width="40%" align="center" border="1">
	<tr><td colspan="2">
	<div style="text-align: center">
	<img src="img/frvlag.jpg" width="24" height="15" alt="frvlag" />
	<input type="radio" name="taal" value="fr" checked="checked" /><strong>Fran&ccedil;ais</strong>&nbsp;&nbsp;
	<img src="img/nlvlag.jpg" width="24" height="15" alt="nlvlag" />
	<input type="radio" name="taal" value="nl" /><strong>Nederlands</strong></td></tr>
	</div>
	<tr><td><strong>Mot de passe / Wachtwoord</strong></td><td><input type="password" name="wachtwoord" /></td></tr>
	<tr><td colspan="2"><div style="text-align: center"><input type="submit" name="Login" value="Login" /></div></td></tr>
	</table>
	</form>
	
<?php
/*else {
	//echo "wachtsessie = $_SESSION[login]";
	Header( "HTTP/1.1 301 Moved Permanently" );
	Header( "Location: index.php" ); 
}*/
include('footer.php');
?>